﻿function loadUserPermission(id, link) {
    var url = base + 'userpermission.ivp/view/'+id;
    var link = $(link);
    var offset = link.offset();

    if ($('#userpermissionedit').length == 0) $('body').append('<div id="userpermissionedit" class="userpermissionedit hidden width450px popupwrapper"></div>');
    var panel = $('#userpermissionedit');

    panel.load(url, { nolayout: 'true', timestamp: new Date() }, function() {
        panel.css('position', 'absolute').css('top', offset.top).css('left', 50);
        panel.bgiframe().show();
    });
    return false;
}

function saveUserPermission() {
    $('#userpermissionedit').hide();
    $.post(base + 'userpermission.ivp/save/', $('#userpermissionform').serializeArray(), function() { loadUsersPermissionTable(); });
    $('#userpermissionedit').remove();
    return false;
}

function loadUsersPermissionTable() {
    $('#wrapper').load(base + 'user.ivp/userspermissions/', { nolayout: 'true', date: new Date().toString() }, '');
    return false;
}